In [1]:
#imports 
import numpy as np
import matplotlib.pyplot as plt

# for numerical inegration
import scipy.integrate

# for pretty plots
import seaborn as sns
sns.set()

# extra packages for interactive plots
import holoviews as hv
import bokeh.io
import panel as pn

bokeh.io.output_notebook()
pn.extension('mathjax')
hv.extension('bokeh')
Loading BokehJS ...

Problem 1: A transcritical bifurcation

$\dot{x} = rx + (x^2)\$

(a).

$\dot{x} = rx + (x^2)\$

0 = x(r+ x)

0 = r + x

My fixed point would be at either 'x' or -r.

(b).

In [36]:
fig, (ax1, ax2, ax3) = plt.subplots(1,3, figsize =[32,8])

x = np.linspace(-1.1,1.1, 100)
y2 = x**2 + r*x

r= -0.5
y1 = r*x + x**2
ax1.plot(x,y1)

r= 0
y1 = r*x + x**2
ax2.plot(x,y1)


r= .5
y1 = r* x +x**2
ax3.plot(x,y1)
Out[36]:
[<matplotlib.lines.Line2D at 0x7fa3a29f6220>]

(c).

At r = -0.5, our two fixed points are x = 0 and x = 0.5. At r = 0 our fixed point is at x = 0. At r = .5, our fixed points are at x = -0.5 and x = 0. As r is negative, it is crossing the x-axis at positive fixed points, but as r is positive, it is crossing the x-axis at positive fixed points. When r was equal to 0, it only crossed the x-axis one time.

(d).

IMG_0498.jpg

Problem 2: A saddle-node bifurcation

$\dot{x} = 1 + rx + x^2 \$

(a).

0 = x^2 + rx + 1

a = 1

b = r

c = 1

$x = \frac{(-r)\pm(sqrt(r^2-4))}{2}$

When you have an r value less than -2 and larger than 2 you would end up having two fixed points due to the plus minus being utilized within the equation. However, if you have any r value equal to 2 or -2 you will be producing a number that will equal 4 and eventually have entire square root equal to 0. This would not utilize the plus minus and therefore result in one fixed point.

(b).

In [8]:
fig, (ax1, ax2, ax3, ax4,ax5) = plt.subplots(1,5, figsize =[32,8])

x = np.linspace(-4,3,100)
y2 = -x**2

r= -3
y1 = 1 + r*x
ax1.plot(x,y1)
ax1.plot(x,y2)

r= -2
y1 = 1 + r*x
ax2.plot(x,y1)
ax2.plot(x,y2)

r= 1
y1 =  1 + r*x
ax3.plot(x,y1)
ax3.plot(x,y2)

r= 2
y1 =  1 + r*x
ax4.plot(x,y1)
ax4.plot(x,y2)

r= 3
y1 =  1 + r*x
ax5.plot(x,y1)
ax5.plot(x,y2)
Out[8]:
[<matplotlib.lines.Line2D at 0x7fa3b05bbaf0>]

(c).

IMG_0499.jpg

(d).

IMG_0500.jpg

(e).

IMG_0501.jpg

Problem 3: Chemical kinetics

(a).

In the first equation, the variables being consumed are A and B which in turn generate 2x. in the second equation, the variables being consumed are X and B which in turn produce C.

(b).

In this equation we can see the relation to the equation above by looking at what our constants are doing. Our constant $k_{1}$ is being multiplied by a and x, which is telling us that this is demonstrating our constant being consumed to produce our product. Our constant $k_{-1}$, represents how the equation is being reveresed and it is being subtracted from our $k_{1}$. It is also being multiplied by the derivative of 2x in an example of the equation being reversed. Now looking at our $k_{2}$ constant, the equation travels in one direction but it is still being substracted from the other two equations. This grouping of variable/constants can still be directly related to our above equations based on the multiplication of itself and the variables x and b.

(c).

$\dot{x} = k_{1}ax- k _{-1}x^2-k_{2}bx$

$\dot{x} = (k_{1}a-k_{2}b)x-(k _{-1})x^2$

In theory, by setting up the equation this way we can assume that ' $k_{1}a-k_{2}b$ ' is equal to $C_{1}$ and ' $k_{-1}$ ' is equal to $C_{2}$ .

(d).

In this solution, we are going to assume that x is equal to '0' to replicate the fixed point at '0'.

$\dot{x} = C_{1}x - C_{2}x^2$

$\ddot{x} = C_{1} - 2C_{2}x$

Now, plug in '0' into my 2nd derrivative.

$\ddot{x} = C_{1} - 2C_{2}(0)$

$\ddot{x} = C_{1}$

$C_{1} = k_{1}a-k_{2}b $

$k_{2}b$ is negative, which leads us to believe that if $k_{2}b > k_{1}a$ , then it will result in $C_{1}$ being negative. This concept is rooted in the idea that our x is equal to '0' and stable.

Problem 4: Model of a fishery

(a).

In [55]:
fig, (ax1, ax2, ax3) = plt.subplots(1,3, figsize =[32,8])

x = np.linspace(-2,3,100)
y2 = -h

r= 0.5
y1 = x*(r-x)
ax1.plot(x,y1)
ax1.plot(x,y2)

r= 1
y1 = x*(r-x)
ax2.plot(x,y1)
ax2.plot(x,y2)

r= 2
y1 = x*(r-x)
ax3.plot(x,y1)
ax3.plot(x,y2)
Out[55]:
[<matplotlib.lines.Line2D at 0x7fa3b21b45b0>]

(b)

$\dot{x} = x(1 −x) - h $

$\dot{x} = x-x^2 - h $

$(\frac{dX}{dT})(-x^2) = (\frac{dX}{dT})(x-h) $

$-2x = 1$

$x= \frac{-1}{2}$

Now, we plug back into the equation.

$ 0 = x-x^2-h $

$ 0 = (\frac{-1}{2})-(\frac{-1}{2})^2-h $

$ 0 = (\frac{-1}{2})-(\frac{1}{4})-h $

$ h = (\frac{-1}{2})-(\frac{1}{4}) $

$ h = (\frac{-2}{4})-(\frac{1}{4}) $

$ h = (\frac{-3}{4}) $

Therfore, our bifurcation happens at $(\frac{-1}{2},\frac{-3}{4})$

(c)

Based on our answer for $h_{c}$ in the previous question, we can use the answer to determine the population effect of our two possiblities, h < $h_{c}$ and h > $h_{c}$. Our population at h > $h_{c}$ will always be at risk of becoming extinct. This also means that our population at h < $h_{c}$ will have an inconsistent rate and will be an unstable population due to it consistently dropping below the fixed point.

In [ ]: